<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>权限管理<!--{if $info['name']}-->--{$info['name']}<!--{/if}--></title>
        <link href="style/default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="./javascript/jquery.js">
        </script>
        <script type="text/javascript" src="./javascript/javascript.js">
        </script>
        <script type="text/javascript">
			var method = eval('({Action_getMethodJson:true})');
            $(function(){
                $('select[name="sort_id"]').click(function(){
                    $('input:radio[name="sort"]').eq(2).attr('checked', true);
                });
				for(var model in method) {
					$('select[name="model"]').append('<option>'+model+'</option>');
				}
				getMethodSelect();
            });
			function getMethodSelect(){
				var model = $('select[name="model"]').val();
				$('select[name="method"]').html('<option value="__FULL__">全部</option>');
				for(var i in method[model]) {
					$('select[name="method"]').append('<option>'+method[model][i]+'</option>');
				}
			}
			function addMethod() {
				var html = '<dd>';
				html += $('select[name="model"]').val() + '-&gt;' + $('select[name="method"]').val();
				html += '<input type="hidden" name="methods[]" value="'+$('select[name="model"]').val() + '.' + $('select[name="method"]').val()+'"/>';
				html += '<img class="but" src="images/delete.gif" onclick="delMethod(this)">';
				html += '<dd>';
				$('dl#method').append(html);
			}
			function delMethod(obj) {
				$(obj).parent().remove();
			}
        </script>
    </head>
    <body>
        <!--{include nav.html}-->
        <div id="main">
            <div style="float:left;">
                <table class="list">
                    <tr>
                        <th width="100">
                            权限名
                        </th>
                        <th width="30">
                            验证
                        </th>
                        <th class="but">
                            <a href="{$url}&amp;m=add"><img src="images/new.gif"></a>
                        </th>
                    </tr>
                    <form method="post">
                        <tr>
                            <td>
                            </td>
                            <td>
                                <!--{Html_getSelect_lib:array('-1'=>'全部','yes'=>'需要', 'no'=>'不需要'),$_GET['auth'],array('name'=>'auth')}-->
                            </td>
                            <td align="center">
                                <input type="submit" name="filter" value="过滤">
                            </td>
                        </tr>
                    </form><!--{foreach $list['data'] $row}-->
                    <tr id="list_{$row['id']}" {if $row['id']==$_GET['id']}class="selected"{/if}>
                        <td nowrap>
							<!--{$row['name']}-->
                        </td>
                        <td align="center">
                            {$row['auth_value']}
                        </td>
                        <td class="but" align="center">
                            <!--{if $row['is_sigle']=='no'}--><a href="{$url}&amp;m=add&id={$row['id']}"><img src="images/new.gif"></a><!--{/if}-->
							<a href="{$url}&m=edit&id={$row['id']}"><img src="images/edit.gif"></a>
							<a href="{$url}&m=del&id={$row['id']}"><img src="images/delete.gif"></a>
                        </td>
                    </tr><!--{/foreach}-->
                </table>
            </div>
            <div style="float:left;margin-left:5px;">
                <form method="post" action="{$url}&amp;m={$_GET['m']}&amp;id={$_GET['id']}">
                    <table class="list">
                        <tr>
                            <th colspan="2">
                                <!--{if $_GET['m']=='edit'}-->修改<!--{elseif $_GET['m']=='del'}-->删除<!--{else}--> 增加<!--{/if}--> 权限
                            </th>
                        </tr>
                        <!--{if $_GET['m']=='del'}-->
                        <tr>
                            <td align="center" colspan="2">
                                确认真的要删除<b>{$info['name']}</b>权限
                                <br>
                                <span class="error">删除后该权限下的所有文章也将被删除</span>
                            </td>
                        </tr>
                        <tr>
                            <th colspan="2">
                                <input type="submit" name="confirm" value="删除"><input type="submit" name="cancel" value="取消">
                            </th>
                        </tr><!--{else}-->
                        <tr>
                            <th>
                                权限名
                            </th>
                            <td>
                                <input type="text" name="name" value="{$info['name']}" class="middle">
                            </td>
                        </tr>
                        <tr>
                            <th>
                                描述<br />200字以内
                            </th>
                            <td>
                                <textarea style="width:250px;height:50px;" name="desc">{$info['desc']}</textarea>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                操作
                            </th>
                            <td>
								<dl id="method">
									<!--{foreach $info['method'] $model $methods}-->
									<!--{foreach $methods $method}-->
									<dd>
										{$model}-&gt;{$method}
										<input type="hidden" name="methods[]" value="{$model}.{$method}"/>
										<img class="but" src="images/delete.gif" onclick="delMethod(this)">
									</dd>
									<!--{/foreach}-->
									<!--{/foreach}-->
								</dl>
								<select name="model" onchange="getMethodSelect()"></select>
								<select name="method"></select>
								<img class="but" src="images/new.gif" onclick="addMethod()">
                            </td>
                        </tr>
						<tr>
                            <th>
                                验证
                            </th>
                            <td>
                                <!--{Html_getSelect_lib:array('yes'=>'需要','no'=>'不需要'),$info['auth'],array('name'=>'auth')}-->
                            </td>
                        </tr>
                        <tr>
                            <th colspan="2">
                                <input type="submit" name="save" value="保存"><input type="submit" name="apply" value="应用"><input type="submit" name="cancel" value="取消"><!--{if $_GET['m']=='edit'}-->
                                <input type="submit" name="del" value="删除"><!--{/if}-->
                            </th>
                        </tr><!--{/if}-->
                    </table>
                </form>
            </div>
        </div>
    </body>
</html>